package com.shanling.shanlingcontroller.persenter

import com.shanling.shanlingcontroller.music.player.SongLoader
import com.shanling.shanlingcontroller.persenter.contract.SingerFragmentContract
import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread

/**
 * Created by ch1 on 2019/11/20.
 */
class SingerPersenter constructor() : RxPresenter<SingerFragmentContract.View>(), SingerFragmentContract.Presenter {
    override fun loadArtists(action: String) {
        mView?.showLoading()
        doAsync {
            val data = SongLoader.getAllArtists()
            uiThread {
                mView?.hideLoading()
                if (data.size > 0) {
                    mView?.showArtists(data)
                } else {
                    mView?.setEmptyView()
                }
            }
        }
    }
}